package com.struts.action;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.interceptor.PreResultListener;
import com.struts.listener.MyPreResult;

public class LoginAction extends ActionSupport{

	private String username ;
	private String password ;
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	
	public String login() {
		
		//自定义运行时异常，测试struts2异常映射处理
		int a = 1 ;
		if(a == 0){
			throw new RuntimeException() ;
		}
		
		//注册PreResultListener监听器
		PreResultListener pr = new MyPreResult() ;
		ActionInvocation invocation = ActionContext.getContext().getActionInvocation() ;
		invocation.addPreResultListener(pr) ;
		
		System.out.println("调用业务处理方法：用户登录处理");
		
		return SUCCESS ;
	}
	
	
}
